package yunjiao.javatutorials.designpatterns.observer;

/**
 * 应用用户
 *
 * @author yangyunjiao
 */
public class AppNotificationSubscriber implements Observer {
    private final String username;

    public AppNotificationSubscriber(String username) {
        this.username = username;
    }

    @Override
    public void update(Subject subject) {
        NewsPublisher publisher = (NewsPublisher) subject;
        System.out.println("向用户 " + username + " 发送应用通知: " +
                publisher.getLatestNews());
    }

    @Override
    public String getName() {
        return username + "(应用用户)";
    }
}
